﻿<?xml version="1.0" encoding="utf-8" ?>
<AdoNetDataAccess connection="$DBConnection$" formatter="bizobj of ApprovalData(approvalSet(approvers),approvalDataChange)">
	<Sql>
		 SELECT
			ApprovalData.ID AS ApprovalDataid
			,ApprovalData.lastUpdateBy as ApprovalDatalastUpdateBy
			,ApprovalDataChange.id as ApprovalDataChangeid
			,ApprovalDataChange.bizObjData as ApprovalDataChangebizObjData
			,ApprovalSet.id as approvalSetid
			,ApprovalSetApprovers.approverId as approversid
		FROM ApprovalData INNER JOIN ApprovalDataChange
			  ON ApprovalData.id= ApprovalDataChange.ApprovalDataId
					   INNER JOIN ApprovalSet ON ApprovalData.ApprovalSetId=ApprovalSet.id
									  INNER JOIN ApprovalSetApprovers ON ApprovalSet.id = ApprovalSetApprovers.approvalSetId
		WHERE ApprovalSet.ObjectType=@typeName
			  AND ApprovalSet.ParentId = ApprovalData.objectId 
					   AND ApprovalData.state=0 AND ApprovalSet.ParentId = @parentId
		ORDER BY ApprovalDataChange.lastInfoDate DESC
	</Sql>
	<Param name="typeName" type="UnicodeVarChar" />
	<Param name="parentId" type="UniqueIdentifier" />
</AdoNetDataAccess>

